

import java.util.*;
import java.io.*;

/**
 * 人物类
 * @author Administrator
 *
 */
public class Person {
	//名字
	private String name;
	//等级
	private int lv;
	//生命
	private int hp;
	//魔法
	private int mp;
	
	/**
	 * 有参构造方法
	 * @param name
	 * @param lv
	 * @param hp
	 * @param mp
	 */
	public Person(String name, int lv, int hp, int mp) {
		
		this.name = name;
		this.lv = lv;
		this.hp = hp;
		this.mp = mp;
	}
	
	/**
	 * 无参构造方法
	 */
	public Person() {
		
		Properties pro = new Properties();
		try {
			
			pro.load(new FileReader("Person.properties"));
			
			this.name = pro.getProperty("name");
			this.lv = Integer.parseInt(pro.getProperty("lv"));
			this.hp = Integer.parseInt(pro.getProperty("hp"));
			this.mp = Integer.parseInt(pro.getProperty("mp"));
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
	
	//重写toString方法
	public String toString(){
		
		return "姓名："+this.name+"，等级："+this.lv+"，生命："+this.hp+"，魔法："+this.mp;
	}
	
	//测试程序
	public static void main(String[] args) {
		
		Person p1 = new Person("孙悟空",10,500,500);
		Person p2 = new Person();
		
		System.out.println(p1);
		System.out.println(p2);
	}

	
	
	public int getHp() {
		return hp;
	}
	public void setHp(int hp) {
		this.hp = hp;
	}
	public int getLv() {
		return lv;
	}
	public void setLv(int lv) {
		this.lv = lv;
	}
	public int getMp() {
		return mp;
	}
	public void setMp(int mp) {
		this.mp = mp;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	
}
